/**
 * @file container.cpp
 * @author ThomasKingFree (dulu150@126.com)
 * @brief
 * @version 0.1
 * @date 2021-03-26
 *
 * @copyright Copyright (c) 2021
 *
 */

#include "widgets/container.h"

#include "utils/gui_dfx.h"

namespace YueGUI {
Container::Container(uint8_t containerVectorSize, uint8_t widgetVectorSize) {
    if (containerVectorSize != 0) {
        containerVector_ = new TinyStd::Vector(containerVectorSize);
    }

    if (widgetVectorSize != 0) {
        widgetVector_ = new TinyStd::Vector(widgetVectorSize);
    }
}

Container::~Container() {
    if (containerVector_ != nullptr) {
        containerVector_->Clear();
    }

    if (widgetVector_ != nullptr) {
        widgetVector_->Clear();
    }
}

bool Container::Add(SimpleWidget &widget) {
    Dfx::Assert(widgetVector_ != nullptr);
    return widgetVector_->Add(&widget);
}

bool Container::Remove(SimpleWidget &widget) {
    Dfx::Assert(widgetVector_ != nullptr);
    return widgetVector_->Remove(&widget);
}

bool Container::Add(Container &container) {
    Dfx::Assert(containerVector_ != nullptr);
    return containerVector_->Add(&container);
}

bool Container::Remove(Container &container) {
    Dfx::Assert(containerVector_ != nullptr);
    return containerVector_->Remove(&container);
}
} // namespace YueGUI
